<template>
  <div class="AssetList">
    <el-main>
      <div>
        <el-row :gutter="20">
          <el-col :span="16">
            <div class="grid-content bg-purple">
              <el-input
                placeholder="请输入关键字进行搜索"
                v-model="keywords"
                id="search"
                class="input-with-select"
                style="width:300px"
              >
                <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
              </el-input>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple" style="0 0 0 40px">
              <el-dropdown @command="handleCommand">
                <el-button type="primary" class="el-dropdown-link">
                  快速处理
                  <i class="el-icon-arrow-down el-icon--right"></i>
                </el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="InUse">在用</el-dropdown-item>
                  <el-dropdown-item command="Scrap">报废</el-dropdown-item>
                  <el-dropdown-item command="Idle">闲置</el-dropdown-item>
                  <el-dropdown-item command="BatchRemove">批量删除</el-dropdown-item>
                  <el-dropdown-item command="BatchImport">
                    <el-button type="text" @click="uploadAsset(innerVisible= true)">批量导入</el-button>
                    <el-dialog
                      width="30%"
                      title="批量导入资产"
                      :visible.sync="innerVisible"
                      append-to-body
                    >
                      <p>1.请选择自定义模块</p>
                      <br>
                      <el-select
                        v-model="impotrtCustomTemplate"
                        placeholder="请选择模块"
                        @change="consolelog"
                      >
                        <el-option
                          v-for="item in options"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        ></el-option>
                      </el-select>
                      <br>
                      <br>
                      <p>2.请按照数据模板的格式准备要导入的格式</p>
                      <br>
                      <el-button type="text" @click="downloadTemplate">下载数据模板</el-button>
                      <br>
                      <div>
                        <h2>注意事项</h2>
                        <p>1.模板中的表头名称不可更改,表头行不能修改;</p>
                        <p>2.项目顺序不可以调整,不需要的项目可以不填写;</p>
                        <p>3.其中资产分类,资产编码,资产名称,所属组织为必填项</p>
                        <p>4.资产编码不可重复;</p>
                        <p>5.导入的文件请勿超过1M.</p>
                      </div>
                      <br>
                      <br>
                      <div>
                        <el-upload
                          ref="upload"
                          :action="requestUrl+'/Upload/UploadAsset'"
                          :on-preview="handlePreview"
                          :on-remove="handleRemove"
                          :on-success="handleSuccess"
                          :file-list="fileList"
                          :auto-upload="false"
                        >
                          <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                        </el-upload>
                      </div>
                      <div slot="footer" class="dialog-footer">
                        <el-button @click="innerVisible = false">取 消</el-button>
                        <el-button type="text" size="small">
                          <el-button
                            style="margin-left: 10px;"
                            size="small"
                            type="success"
                            @click="submitUpload"
                          >开始导入</el-button>
                        </el-button>
                      </div>
                    </el-dialog>
                  </el-dropdown-item>
                  <el-dropdown-item command="ExportEXCEL">导出Excel</el-dropdown-item>
                  <el-dropdown-item command="Download">下载入库单</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="grid-content bg-purple">
              <el-button icon="el-icon-printer" @click="PrintLable">打印标签</el-button>
            </div>
          </el-col>
        </el-row>
      </div>
        <br>
      <el-table
        ref="multipleTable"
        :data="tableData3"
        border
        stripe
        height="383"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="state" label="状态" width="150" :formatter="formatState"></el-table-column>
        <el-table-column prop="pictureUrl" label="照片" width="120">
          <!-- 图片的显示 -->
          <template slot-scope="scope">
            <img
              v-if="scope.row.pictureUrl"
              :src="requestUrl+scope.row.pictureUrl"
              min-width="80"
              height="80"
              @click="lookBigImage(scope.row.pictureUrl)"
            >
          </template>
        </el-table-column>
        <el-table-column prop="assetCode" label="资产编号" width="120">
          <!-- <el-button
            @click="dialogFormVisible = true" v-model="tableData3.assetCode"
          >{{tableData3.assetCode}}</el-button>-->
        </el-table-column>
        <el-table-column prop="assetName" label="资产名称" width="120"></el-table-column>
        <el-table-column prop="standardType" label="规格" width="200"></el-table-column>
        <el-table-column prop="sn" label="SN号" width="120"></el-table-column>
        <el-table-column prop="unit" label="计量单位" width="120"></el-table-column>
        <el-table-column prop="amount" label="金额(单位:万元)" width="200"></el-table-column>
        <!-- <el-table-column prop="ownOrganizationName" label="使用公司" width="120"></el-table-column> -->
        <el-table-column prop="useOrganizationName" label="使用部门" width="120"></el-table-column>
        <el-table-column prop="buyDate" label="购入时间" width="120"></el-table-column>
        <el-table-column prop="useUser" label="使用人" width="120"></el-table-column>
        <el-table-column prop="ownOrganizationName" label="所属公司" width="200"></el-table-column>
        <el-table-column prop="area" label="区域" width="120"></el-table-column>
        <el-table-column prop="storageLocation" label="存放地点" width="120"></el-table-column>
        <el-table-column prop="deadLine" label="使用期限(月)" width="120"></el-table-column>
        <el-table-column prop="assetAdmin" label="管理员" width="120"></el-table-column>
        <el-table-column fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <el-button @click="EditAsset(scope.row)" type="text" size="small" class="EditAsset">编辑</el-button>
            <el-button class="clear" @click="clear(scope.row)" type="text" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- </div> -->
      <el-dialog title="资产详情" :visible.sync="dialogFormVisible" width="80%">
        <el-form :model="ruleForm">
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="资产编号" prop="assetCode" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.assetCode" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="资产类别" prop="assetTypeId" :label-width="formLabelWidth">
                  <el-select
                    v-model="ruleForm.assetTypeId"
                    @change="consolelog1"
                    placeholder="资产类别"
                    style="width: 228px"
                  >
                    <el-option
                      v-for="item in list1"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="资产名称" prop="assetName" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.assetName" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="所属公司" prop="ownOrganizationName" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.ownOrganizationName" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="区域" prop="area" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.area" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="购入时间" prop="buyDate" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.buyDate" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="计量单位" prop="unit" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.unit" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="规格型号" prop="standardType" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.standardType" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="SN     号" prop="sn" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.sn" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="存放地点" prop="storageLocation" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.storageLocation" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="金      额" prop="amount" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.amount" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="使用部门" prop="useOrganizationName" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.useOrganizationName" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="使用期限" prop="deadLine" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.deadLine" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="使用人" prop="useUser" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.useUser" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="来源" prop="from" :label-width="formLabelWidth">
                  <el-select v-model="ruleForm.from" style="width: 227px">
                    <el-option label="购入" value="0"></el-option>
                    <el-option label="自建" value="1"></el-option>
                    <el-option label="租赁" value="2"></el-option>
                    <el-option label="捐赠" value="3"></el-option>
                    <el-option label="内部购入" value="4"></el-option>
                    <el-option label="其他" value="5"></el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="管理员" prop="assetAdmin" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.assetAdmin" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="照片" prop="pictureUrl" :label-width="formLabelWidth">
                  <el-upload
                    class="avatar-uploader"
                    :action="requestUrl+'Upload/UploadImage'"
                    :show-file-list="false"
                    :on-success="handleAvatarSuccess"
                    :before-upload="beforeAvatarUpload"
                  >
                    <img
                      v-if="ruleForm.pictureUrl"
                      :src="requestUrl+ruleForm.pictureUrl"
                      class="avatar"
                    >
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  </el-upload>
                </el-form-item>
              </div>
            </el-col>
            <el-col :span="8">
              <div class="grid-content bg-purple">
                <el-form-item label="备注" prop="remark" :label-width="formLabelWidth">
                  <el-input v-model="ruleForm.remark" auto-complete="off"></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <!-- 新增属性 -->
          <el-row>
            <el-col :span="8" v-for="item in ruleForm.expandList" :key="item.key">
              <div class="grid-content bg-purple">
                <el-form-item
                  :label="item.name"
                  :id="item.key"
                  prop="expandList"
                  :label-width="formLabelWidth"
                >
                  <el-input v-model="item.value"></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="saveData">确 定</el-button>
        </div>
      </el-dialog>
      <el-dialog class="imgDialog" title="查看图片" :visible.sync="dialogImageVisible" width="40%">
        <img :src="showImageUrl" alt="资产图片" height="80%" width="100%">
      </el-dialog>
      <br>
      <div class="block">
        <el-row :gutter="20">
          <el-col :span="4">
            <div class="grid-content bg-purple">
              <span class="demonstration">已选择{{this.assetList.length}}条</span>
            </div>
          </el-col>
          <el-col :span="10">
            <div class="grid-content bg-purple">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage4"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="10"
                layout="prev, pager, next, sizes, jumper"
                :total="this.total"
              ></el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-main>
  </div>
</template>
<script>
import { axiosPost, axiosGet, requestUrl, axiosDownLoad } from "@/api/index.js";
import { debug } from "util";
import { truncate, truncateSync } from "fs";
export default {
  data() {
    return {
      keywords: "",
      total: 0,
      page: 1,
      pageSize: 10,
      tableData3: [],
      currentPage1: 5,
      currentPage2: 5,
      currentPage3: 5,
      currentPage4: 1,
      assetList: [],
      dialogTableVisible: false,
      dialogFormVisible: false, //点击边界的弹框
      innerVisible: false,
      dialogImageVisible: false,
      requestUrl: requestUrl,
      ruleForm: {
        id: "",
        templateId: "",
        assetCode: "",
        assetType: "",
        assetName: "",
        ownOrganizationName: "",
        useOrganizationName: "",
        area: "",
        imageUrl: "",
        remark: "",
        buyDate: "",
        standardType: "",
        sn: "",
        unit: "",
        amount: "",
        storageLocation: "",
        deadLine: "",
        useUser: "",
        from: "",
        assetAdmin: "",
        pictureUrl: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
        expandList: [],
        assetExpandList: []
      },
      formLabelWidth: "120px",
      showImageUrl: "",
      list1: [],
      options: [{}],
      value: "",
      file1: "",
      uploadFile: "",
      impotrtCustomTemplate: "",
      fileList: [
        /* {name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'} */
      ]
    };
  },
  //调用获取资产列表接口数据
  beforeMount() {
    this.getAssetList();
  },
  methods: {
    // toggleSelection(rows) {
    //   if (rows) {
    //     rows.forEach(row => {
    //       this.$refs.multipleTable.toggleRowSelection(row);
    //     });
    //   } else {
    //     this.$refs.multipleTable.clearSelection();
    //   }
    // },
    //点击开始导入按钮事件
    submitUpload() {
      this.$refs.upload.submit();
    },
    //文件上传
    handleChange(file, fileList) {
      // console.log(file);
      this.fileList3 = fileList.slice(-3);
    },
    handleRemove(file, fileList) {
      var file1 = file;
      // console.log(file1);
    },
    handlePreview(file) {
      // console.log(file);
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    consolelog() {},
    handleSuccess(res) {
      // console.log(file);
      if (res.success == true) {
        this.uploadFile = res.data.url;
        this.importFiles();
      }
    },
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
      // console.log(this.imageUrl);
      // console.log(res);
      console.log(res);
      this.ruleForm.pictureUrl = res.data.url;
      // console.log(this.ruleForm.pictureUrl);

      // console.log(file);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
    //分页
    handleSelectionChange(selection, row) {
      this.assetList = selection;
      // console.log(this.assetList); //选中的资产列表(行数)
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getAssetList();
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.page = val;
      this.getAssetList();
    },
    //将数据库对应的数字转换成在用 闲置 报废
    formatState: function(row, column) {
      return row.state === 1 ? "闲置" : row.state === 2 ? "在用" : "报废";
    },
    //编辑
    EditAsset(row) {
      this.dialogFormVisible = true; //显示dialog
      axiosGet(
        "/Asset/GetOneAsset?id=" + row.id + "&templateId=" + row.templateId
      ).then(res => {
        if (res.status == 200 && res.data.success) {
          this.ruleForm = res.data.data;
          console.log(this.ruleForm);
        } else {
          this.$message({
            type: "fail",
            message: res.data.message
          });
        }
      });
      //资产类别
      axiosGet("Asset/GetAssetTypeList", null).then(res => {
        if (res.status === 200 && res.data.success) {
          this.list1 = res.data.data;
        }
      });
    },
    consolelog1() {},
    //获取资产列表数据接口用函数封装起来
    getAssetList: function() {
      var key1 = this.keywords;
      var bean = {
        page: this.page,
        pageSize: this.pageSize,
        key: key1,
        userId: localStorage.getItem("userId")
      };
      axiosGet("/Asset/GetAssetList", bean).then(res => {
        if (res.status == 200 && res.data.success) {
          this.tableData3 = res.data.data.list;
          this.total = res.data.data.total;
        }
      });
    },
    //保存新增数据接口
    saveData() {
      // console.log(this.ruleForm);
      this.ruleForm.assetExpandList = JSON.stringify(this.ruleForm.expandList);
      this.ruleForm.expandList = [];
      axiosPost("Asset/EditAsset", this.ruleForm).then(res => {
        if (res.status === 200 && res.data.success) {
          this.dialogFormVisible = false;
          this.getAssetList();
          this.$message({
            type: "success",
            message: res.data.message
          });
        } else {
          this.$message({
            type: "fail",
            message: res.data.message
          });
        }
      });
    },
    //搜索资产
    search() {
      // console.log(this.keywords);
      this.getAssetList();
    },
    // 删除资产
    clear(index) {
      // console.log(this.tableData3);

      this.$confirm("你确定要删除该资产吗？", "删除资产", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let delIdList = [];
          if (index) {
            delIdList.push({ id: index.id });
          } else {
            this.assetList.forEach(item => {
              delIdList.push({ id: item.id });
            });
          }
          // console.log(JSON.stringify(this.assetList));
          axiosPost("/Asset/DeleteAsset", {
            assetList: JSON.stringify(delIdList)
          }).then(res => {
            if (res.status === 200) {
              var type = "success";
              if (res.data.success) {
                // 删除成功了重新获取资产列表接口数据
                // this.$refs.multipleTable.clearSelection();
                this.getAssetList();
                type = "success";
              } else {
                type = "fail";
              }
              this.$message({
                type: type,
                message: res.data.message
              });
            } else {
              this.$message({
                type: "error",
                message: "删除失败!"
              });
            }
          });
        })
        .catch(err => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },

    lookBigImage(imageUrl) {
      // this.dialogImageVisible=true;
      // this.showImageUrl= "http://wxtest.trfriend.com:12135/"+imageUrl;
    },

    //快速处理的弹框事件
    handleCommand(command) {
      // this.$message('click on item ' + command);

      //判断点击事件是批量删除,调用删除事件,进行删除操作

      //1表示闲置 2表示在用  3表示报废
      if ("BatchRemove" == command) {
        this.clear();
      } else if ("InUse" == command) {
        this.updateState(2);
      } else if ("Scrap" == command) {
        this.updateState(3);
      } else if ("Idle" == command) {
        this.updateState(1);
      } else if ("ExportEXCEL" == command) {
        this.ExportAssetInfo();
        // }else if(){
      }
    },
    //批量修改资产状态接口
    updateState: function(state) {
      var arr = [];
      for (var i = 0; i < this.assetList.length; i++) {
        var assetId = this.assetList[i].id;
        var bean = { id: assetId, state: state };
        arr.push(bean);
      }
      // console.log(arr);
      var bean = { assetList: JSON.stringify(arr) };
      axiosPost("Asset/UpdateAssetState", bean).then(res => {
        if (res.status === 200 && res.data.success) {
          // console.log(res.data.data);
          //更新成功后重新获取资产列表接口数据
          this.assetList = [];
          this.$refs.multipleTable.clearSelection();
          this.getAssetList();
          this.$message({
            type: "success",
            message: "状态更改成功!"
          });
        }
      });
    },

    //点击批量导入资产的时候调用模块列表接口
    uploadAsset() {
      //模块列表接口
      axiosGet("Asset/GetTemplateList", null).then(res => {
        if (res.status === 200 && res.data.success) {
          this.options = res.data.data;
        }
      });
    },
    importFiles() {
      //文件上传接口
      // console.log(this.file1);
      // var assetTypeId = this.options[0].assetTypeId;
      // var templateId = this.options[0].id;
      // var filePath = this.uploadFile;

      var be = {};
      for (var i = 0; i < this.options.length; i++) {
        if (this.impotrtCustomTemplate == this.options[i].id) {
          be = this.options[i];
        }
      }

      var assetTypeId = be.assetTypeId;
      var templateId = be.templateId;
      var filePath = this.uploadFile;

      /* console.log(assetTypeId);
      console.log(templateId); */
      var bean = {
        assetTypeId: assetTypeId,
        templateId: templateId,
        filePath: filePath
      };
      axiosPost("/Asset/ImportAsset", bean).then(res => {
        if (res.status === 200 && res.data.success) {
          // this.options = res.data.data;
          this.$message({
            showClose: true,
            message: "导入成功",
            type: "success"
          });
          // this.$refs.upload.clearFiles();
        } else {
          this.$message({
            showClose: "error",
            message: "文件导入失败!",
            type: "error"
          });
        }
      });
    },
    //下载模板接口
    downloadTemplate() {
      var be = {};
      for (var i = 0; i < this.options.length; i++) {
        if (this.impotrtCustomTemplate == this.options[i].id) {
          be = this.options[i];
        }
      }

      var assetTypeId = be.assetTypeId;
      var templateId = be.templateId;

      window.location.href =
        requestUrl +
        "Asset/DownloadTemplate?assetTypeId=" +
        assetTypeId +
        "&templateId=" +
        templateId;
    },
    //导出资产列表
    ExportAssetInfo: function() {
      var key1 = this.keywords;
      var bean = { key: key1 };
      window.location.href = requestUrl + "Asset/ExportAssetInfo";
    },
    //打印标签接口
    PrintLable() {
      // console.log(this.assetList);
      // console.log(JSON.stringify(this.assetList));
      if (this.assetList.length < 1) {
        this.$message({
          type: "error",
          message: "请勾选要打印的资产!",
          showClose: true
        });
      }
      var bean = { assetList: JSON.stringify(this.assetList) };
      axiosDownLoad("Asset/PrintLable", bean).then(res => {
        console.log(res);
        const blob = new Blob([res.data], { type: "application/pdf" });
        const url = window.URL || window.webkitURL || window.moxURL;
        const downloadHref = url.createObjectURL(blob);
        let downloadLink = document.createElement("a");
        downloadLink.href = downloadHref;
        downloadLink.download = "打印标签.pdf";
        downloadLink.click();
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.AssetList {
  height: 100%;
}
.avatar {
  width: 100px;
  height: 100px;
  display: block;
}
</style>
